<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('产品列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>工作组：</label>
                            <select name="deptId" id="deptId" class="form-control " th:with="dept=${@deptService.selectChildrenDeptById(103)}" onChange="selectDept()">
                                <option value="">全部</option>
                                <option th:each="d : ${dept}" th:text="${d.deptName}" th:value="${d.deptId}" ></option>
                            </select>
                        </li>
                        <li>
                            <label>姓名：</label>
                            <select name="userId" id="userId" class="form-control">
                                <option value="">全部</option>
                            </select>
                        </li>
                        <li>
                            <label>产品/项目：</label>
                            <select name="productType" id="productType" onChange="selectProduct()">
                                <option value="">全部</option>
                                <option value="0">产品</option>
                                <option value="1">项目</option>
                            </select>
                        </li>
                        <li>
                            <label>产品/项目名称：</label>
                            <select name="productId" id="productId" class="form-control">
                                <option value="">全部</option>
                            </select>
                        </li>
                        <li>
                            <label>起始日期：</label>
                            <input type="text" class="time-input" placeholder="请选择查询起始日期" name="startDate"/>
                        </li>
                        <li>
                            <label>到</label>
                            <input type="text" class="time-input" placeholder="请选择查询截止日期" name="endDate"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:weekly:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<th:block th:include="include :: bootstrap-table-fixed-columns-js" />
<script th:inline="javascript">
    var prefix = ctx + "system/product";
    function selectDept(){
        var url;
        var deptId=$("#deptId").val();
        if ('' == deptId) {
            return;
        }
        url = "/system/user/list/"+ deptId;
        $.ajax({
            cache: true,
            type: "GET",
            url: url,
            async: false,
            success: function(result) {
                data = result.data
                if (result.code == web_status.SUCCESS) {
                    $('#userId').empty().append('<option value="">全部</option>');
                    for(var i in data){
                        var userId = data[i].userId;
                        var userName =data[i].userName;
                        $('#userId').append
                        ('<option value="'+userId+'">'+userName+'</option>');
                    };
                    $('#userId').selectpicker('refresh');
                    $('#userId').selectpicker('render');
                } else {
                    $.modal.alertError(result.msg);
                }
            }
        });
    }
    function selectProduct(){
        var url;
        var productType=$("#productType").val();
        if ('' == productType) {
            return;
        }
        url = "/system/product/"+ productType;
        $.ajax({
            cache: true,
            type: "GET",
            url: url,
            async: false,
            success: function(result) {
                data = result.data
                if (result.code == web_status.SUCCESS) {
                    $('#productId').empty().append('<option value="">全部</option>');
                    for(var i in data){
                        var productId = data[i].productId;
                        var productName =data[i].productName;
                        $('#productId').append
                        ('<option value="'+productId+'">'+productName+'</option>');
                    };
                    $('#productId').selectpicker('refresh');
                    $('#productId').selectpicker('render');
                } else {
                    $.modal.alertError(result.msg);
                }
            }
        });
    }
    function initialDate(){
        var lastMonday=[[${lastMonday}]]
        $("input[name='startDate']").val(lastMonday);
        var lastFriday=[[${lastFriday}]]
        $("input[name='endDate']").val(lastFriday);
    }
    $(function() {
        initialDate();
        var options = {
            url: prefix + "/statistics",
            exportUrl: prefix + "/export",
            modalName: "周报统计",
            showToggle: false,
            fixedColumns: true,
            fixedNumber: 5,
            columns: [{
                checkbox: true
            },
                {
                    field: 'weeklyId',
                    title: '周报id',
                    visible: false
                },
                {
                    field: 'weeklyDateStart',
                    title: '周报开始日期'
                },
                {
                    field: 'weeklyDateEnd',
                    title: '周报截止日期'
                },
                {
                    field: 'deptName',
                    title: '工作组',
                    class: 'text-nowrap'
                },
                {
                    field: 'productName',
                    title: '产品/项目名称',
                    class: 'text-nowrap',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    field: 'process',
                    title: '工作进度'
                },
                {
                    field: 'isDelayDesc',
                    title: '是否延期'
                },
                {
                    field: 'workTime',
                    title: '实际工时'
                },
                {
                    field: 'standardTime',
                    title: '标准工时'
                },
                {
                    field: 'workTimeDiff',
                    title: '工时差'
                },
                {
                    field: 'planDemandAmountTotal',
                    title: '计划完成需求合计'
                },
                {
                    field: 'actualDemandAmountTotal',
                    title: '实际完成需求合计'
                },
                {
                    field: 'planTaskAmountTotal',
                    title: '计划完成任务合计'
                },
                {
                    field: 'actualTaskAmountTotal',
                    title: '实际完成任务合计'
                },
                {
                    field: 'toTestAmountTotal',
                    title: '产品转测合计'
                },
                {
                    field: 'newBugAmountTotal',
                    title: '新增缺陷合计'
                },
                {
                    field: 'fixBugAmountTotal',
                    title: '修复缺陷合计'
                },
                {
                    field: 'productExperienceAmountTotal',
                    title: '产品体验数量合计'
                },
                {
                    field: 'productExperiencePassAmountTotal',
                    title: '产品体验通过数量合计'
                },
                {
                    field: 'designReviewAmountTotal',
                    title: '产品设计评审会议数量'
                },
                {
                    field: 'designReviewPassAmountTotal',
                    title: '产品设计评审会议通过数量'
                },
                {
                    field: 'detectBugAmountTotal',
                    title: '新增缺陷合计'
                },
                {
                    field: 'closeBugAmountTotal',
                    title: '修复缺陷合计'
                },
                {
                    field: 'deployProductAmountTotal',
                    title: '配置项目产品合计'
                },
                {
                    field: 'documentAmountTotal',
                    title: '文档贡献数量合计'
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>